1 00:00:00,600 --> 00:00:06,600 So let's put a message frame on our window so that when we get we get some sort of information we want 2 00:00:06,600 --> 00:00:09,500 to give the user, it's going to display up top. 3 00:00:09,510 --> 00:00:17,460 I'm going to go to my starter g UI screen, g UI shop frame, top bar frame. 4 00:00:17,460 --> 00:00:22,170 And on that when I hit the plus sign, I'm going to add text label. 5 00:00:22,320 --> 00:00:23,250 There we go. 6 00:00:23,250 --> 00:00:27,210 And I'm going to call this message label if I can click it. 7 00:00:27,210 --> 00:00:27,630 There we go. 8 00:00:27,630 --> 00:00:28,320 I got it. 9 00:00:28,470 --> 00:00:30,630 Message label. 10 00:00:31,050 --> 00:00:39,210 I'm going to make the anchor ..5.5 because I'm going to center it on this top, this top bar frame. 11 00:00:39,300 --> 00:00:41,910 I take that anchor point right there and put it in the center. 12 00:00:41,910 --> 00:00:42,990 So. 13 00:00:43,470 --> 00:00:49,050 Well, while we're here on background transparency, if you can't quite see that, let me move that 14 00:00:49,050 --> 00:00:49,550 out. 15 00:00:49,560 --> 00:00:50,850 Background transparency. 16 00:00:50,850 --> 00:00:52,020 Let's make that a one. 17 00:00:52,350 --> 00:00:52,550 Right. 18 00:00:52,590 --> 00:00:56,730 We don't need the background and let's go down a little more position. 19 00:00:56,730 --> 00:00:57,030 All right? 20 00:00:57,030 --> 00:01:06,270 This is what's going to change where my my labels at 0.5 on the X comma, zero pixel offset comma 0.5 21 00:01:06,270 --> 00:01:09,510 and the Y comma, zero pixel offset. 22 00:01:10,170 --> 00:01:10,650 All right. 23 00:01:10,650 --> 00:01:18,870 And then the size well, let's see, X, we don't want to make it the full size. 24 00:01:19,230 --> 00:01:20,760 The demo I made a 0.6. 25 00:01:20,760 --> 00:01:28,020 I think I'm going to make a 0.8 on the x zero pixel offset and then one for the Y. 26 00:01:28,020 --> 00:01:30,030 That's the full height of the bar. 27 00:01:30,030 --> 00:01:31,770 Zero pixel offset. 28 00:01:32,160 --> 00:01:33,240 Oh, that's good. 29 00:01:33,240 --> 00:01:34,260 Yeah, that'll work. 30 00:01:34,260 --> 00:01:34,890 That'll work. 31 00:01:34,890 --> 00:01:41,520 Let's scroll down a little more and I'm going to change the font face to comic. 32 00:01:42,270 --> 00:01:43,320 So we make a bold. 33 00:01:43,320 --> 00:01:44,280 Sure. 34 00:01:45,070 --> 00:01:50,970 And then the text, I'm going to actually clear that out, but not until I'm done with everything else. 35 00:01:50,980 --> 00:01:52,540 Make the text color three. 36 00:01:52,540 --> 00:01:54,100 I'm going to make that like a really red. 37 00:01:55,160 --> 00:01:57,900 Because we want them to read it and then text scale. 38 00:01:57,920 --> 00:02:04,490 You can try and pick a text size, but just be aware that you want that text size to change depending 39 00:02:04,490 --> 00:02:05,480 on the window size. 40 00:02:05,510 --> 00:02:11,540 We've already run into problems with that, so we could put a little text transparency around it too, 41 00:02:11,570 --> 00:02:12,680 if you want. 42 00:02:12,710 --> 00:02:13,850 Maybe we'll do that. 43 00:02:13,850 --> 00:02:16,700 So text stroke, transparency, make that zero. 44 00:02:17,750 --> 00:02:21,410 That makes it pretty easy to see. 45 00:02:21,850 --> 00:02:23,210 Might be a little too much. 46 00:02:23,210 --> 00:02:24,680 I think I'll keep it, though. 47 00:02:25,010 --> 00:02:25,400 All right. 48 00:02:25,400 --> 00:02:27,890 Now I can get rid of that label. 49 00:02:27,890 --> 00:02:29,720 We know what everything looks like. 50 00:02:30,980 --> 00:02:31,910 There we go. 51 00:02:32,750 --> 00:02:38,600 Now let's add some code so that we can send messages to our message label if something goes wrong with 52 00:02:38,600 --> 00:02:39,500 the purchase. 53 00:02:39,530 --> 00:02:43,800 I'm going to open up my shop script, which is under the shop frame, which is in the screen. 54 00:02:43,820 --> 00:02:44,420 Gooey. 55 00:02:44,510 --> 00:02:45,210 There we go. 56 00:02:45,230 --> 00:02:48,590 Opened it up and near the top in the variable section. 57 00:02:49,040 --> 00:02:50,570 The last variable. 58 00:02:50,570 --> 00:02:50,960 And you. 59 00:02:50,990 --> 00:02:52,370 But you could add it anywhere. 60 00:02:52,400 --> 00:03:00,620 I'm going to add a variable or message label and it's going to be on the shop frame, top bar frame. 61 00:03:00,620 --> 00:03:02,450 And it is called message label. 62 00:03:03,170 --> 00:03:04,160 Nice. 63 00:03:04,220 --> 00:03:04,670 All right. 64 00:03:04,670 --> 00:03:10,700 Now I see this preview item where we when we click on our items, we're going to get our image and the 65 00:03:10,700 --> 00:03:12,000 text and the price. 66 00:03:12,020 --> 00:03:13,100 I'm going to use this. 67 00:03:13,100 --> 00:03:14,750 I'm going to copy this. 68 00:03:15,200 --> 00:03:24,260 Control C and then right underneath it, Control V, I'm going to make another function called Clear 69 00:03:24,620 --> 00:03:29,900 Fields and I'm going to get rid of I'm going to get rid of that button. 70 00:03:29,900 --> 00:03:30,810 I don't need it. 71 00:03:30,830 --> 00:03:33,890 What I really needed were these three values. 72 00:03:33,890 --> 00:03:35,840 So I have my preview image. 73 00:03:35,840 --> 00:03:41,840 I'm going to delete that value that I'm assigning because we're clearing the fields here and I'll delete 74 00:03:41,840 --> 00:03:43,050 this one. 75 00:03:43,070 --> 00:03:44,660 I'm putting these single quotes here. 76 00:03:44,660 --> 00:03:46,010 It's an empty string. 77 00:03:46,010 --> 00:03:48,290 I want to delete that one empty string. 78 00:03:48,290 --> 00:03:52,220 So two single quotes, Empty string. 79 00:03:52,220 --> 00:03:53,690 Empty string, Empty string. 80 00:03:53,690 --> 00:03:57,140 Also, let's clear out our message label. 81 00:03:57,140 --> 00:03:57,530 Right. 82 00:03:57,530 --> 00:03:58,160 Something. 83 00:03:58,160 --> 00:04:01,460 Something happened where we don't need messages anymore. 84 00:04:01,460 --> 00:04:02,390 Like a new purchase. 85 00:04:02,390 --> 00:04:04,370 We close the window, something like that. 86 00:04:04,370 --> 00:04:06,680 So we're just clearing everything out. 87 00:04:07,100 --> 00:04:07,520 Cool. 88 00:04:07,520 --> 00:04:09,710 We didn't call that yet, but keep that in mind. 89 00:04:09,920 --> 00:04:17,270 Let's scroll down below our for loop the populates, our text buttons and maybe right underneath that 90 00:04:17,270 --> 00:04:19,700 for loop before the events. 91 00:04:19,700 --> 00:04:21,710 So I have my shop re event. 92 00:04:22,010 --> 00:04:27,860 I'm going to make a function local function called is owned. 93 00:04:27,860 --> 00:04:31,520 We're going to check to see if we own the thing that we're buying. 94 00:04:31,520 --> 00:04:33,290 We don't want to buy things twice. 95 00:04:33,650 --> 00:04:35,180 I'm going to pass in a player. 96 00:04:35,180 --> 00:04:40,940 Although player is global in this script, I may want to break this script out, this function out somewhere 97 00:04:40,940 --> 00:04:41,450 else. 98 00:04:41,450 --> 00:04:42,770 I'm going to pass it in. 99 00:04:43,010 --> 00:04:48,290 And then the item, the item that we're checking for, see if it's owned. 100 00:04:48,440 --> 00:04:52,160 I need to get a character to see if it's on my character. 101 00:04:52,160 --> 00:04:56,300 So if it's a hat, I might be wearing it, or if it's a gun, it might be my hand. 102 00:04:56,300 --> 00:04:57,860 We're going to need the character. 103 00:04:57,860 --> 00:04:59,480 We're going to get that from the player. 104 00:04:59,480 --> 00:05:06,680 So player, dot character or player dot character added. 105 00:05:06,680 --> 00:05:12,020 Wait, just in case the character is not quite ready, we're going to wait for the character at an event 106 00:05:12,020 --> 00:05:17,120 to fire that says, Hey, wait there till that fires, and then we're going to have the character. 107 00:05:17,120 --> 00:05:19,970 Char is going to have the character pretty good. 108 00:05:20,480 --> 00:05:20,750 All right. 109 00:05:20,780 --> 00:05:29,450 And now what we're going to do is we're going to check to see if we can find an own item on the character. 110 00:05:29,450 --> 00:05:33,410 When we do a find first child. 111 00:05:33,800 --> 00:05:39,650 No, no, no speech Quotes of type, item of name item. 112 00:05:39,650 --> 00:05:44,300 So we're passing a string in here, so we're going to pass the string in, let's say simple pistol. 113 00:05:44,300 --> 00:05:46,700 We're going to look in the character and see if we find it. 114 00:05:46,700 --> 00:05:48,860 If we do, we own the item. 115 00:05:48,860 --> 00:05:50,180 At least it's on a character. 116 00:05:50,180 --> 00:05:56,090 So I'll do an if owned item. 117 00:05:56,090 --> 00:05:58,850 Then let's send a message. 118 00:05:58,940 --> 00:06:07,940 Message label text equals bound the item exclamation mark. 119 00:06:08,090 --> 00:06:14,000 It was equipped, it was equipped, it was on the character. 120 00:06:14,000 --> 00:06:17,820 Then we're going to return true, right? 121 00:06:17,900 --> 00:06:24,440 So when I call this function, the return value is going to be a true if it was actually on the character, 122 00:06:24,440 --> 00:06:26,450 but it might be in the backpack. 123 00:06:27,140 --> 00:06:29,840 So I'm going to get that owned item again. 124 00:06:29,840 --> 00:06:31,040 If we get down here. 125 00:06:31,040 --> 00:06:33,470 We know that this didn't happen, right? 126 00:06:33,470 --> 00:06:34,220 We didn't return it. 127 00:06:34,220 --> 00:06:34,760 True. 128 00:06:34,760 --> 00:06:36,440 I'm going to get owned item. 129 00:06:36,710 --> 00:06:41,520 I'm going to look at the player and on the player there's something called a backpack, right? 130 00:06:41,540 --> 00:06:46,640 That's the little squares down on the bottom of your screen as the pistol and the lemon and then the 131 00:06:46,640 --> 00:06:47,180 backpack. 132 00:06:47,180 --> 00:06:50,420 We can do a find first child. 133 00:06:50,420 --> 00:06:54,440 And then if we find the item, oh, it's in the backpack. 134 00:06:54,440 --> 00:06:55,640 So I'm going to check again. 135 00:06:55,640 --> 00:07:00,740 If I owned item, then why did I do this twice? 136 00:07:00,740 --> 00:07:02,870 Why didn't I just combine these ifs? 137 00:07:02,870 --> 00:07:07,220 Well, I just wanted to show you the difference that sometimes it's equipped, sometimes it's in the 138 00:07:07,220 --> 00:07:07,880 backpack. 139 00:07:07,880 --> 00:07:10,850 You could certainly could combine those. 140 00:07:10,850 --> 00:07:11,140 Right. 141 00:07:11,150 --> 00:07:16,190 But now I thought that would be kind of cool to see how it's how you can look for things that are in 142 00:07:16,190 --> 00:07:17,300 different places. 143 00:07:17,900 --> 00:07:18,980 So we got our message. 144 00:07:18,980 --> 00:07:29,690 Label text equals, let's say, found the item, but this time it was in the backpack. 145 00:07:32,370 --> 00:07:33,490 And that's nothing good. 146 00:07:33,520 --> 00:07:33,990 Oh, don't forget. 147 00:07:33,990 --> 00:07:34,980 We got to return. 148 00:07:35,140 --> 00:07:35,350 Right. 149 00:07:35,370 --> 00:07:36,210 We found it. 150 00:07:36,570 --> 00:07:38,520 Return True. 151 00:07:38,950 --> 00:07:41,540 All right, so those are the two cases that we're going to look for. 152 00:07:41,550 --> 00:07:42,390 If it's owned. 153 00:07:42,390 --> 00:07:43,650 We don't have any other places. 154 00:07:43,650 --> 00:07:44,580 We're going to put it. 155 00:07:45,560 --> 00:07:50,530 And now down here in the activated, right, this is where we do the purchase. 156 00:07:50,540 --> 00:07:59,270 We have the buy button, we activated it and we need to check to see if it's owned right here. 157 00:07:59,270 --> 00:08:02,090 We're checking to see that somebody selected something. 158 00:08:02,090 --> 00:08:02,450 Right. 159 00:08:02,450 --> 00:08:05,690 The text is not equal to the empty string. 160 00:08:06,020 --> 00:08:08,120 So let me put a note here. 161 00:08:08,120 --> 00:08:15,560 I'm going to say something was selected. 162 00:08:15,560 --> 00:08:17,090 That's the F statement. 163 00:08:17,180 --> 00:08:23,450 I'll say if something was selected, because this is going to get a little bit a little bit hard, because 164 00:08:23,450 --> 00:08:28,040 what I'm going to do is right in between these two s, I'm going to add another F, I'm going to say, 165 00:08:28,040 --> 00:08:38,570 if not is owned, we're going to pass in the player and the item, but we don't have the item. 166 00:08:38,570 --> 00:08:43,460 What we do is we have the preview name text, which is actually the item. 167 00:08:44,180 --> 00:08:45,350 Copy. 168 00:08:47,390 --> 00:08:48,500 Paste. 169 00:08:48,500 --> 00:08:57,980 So if not is owned passing the player, passing the thing we're checking for then down here above where 170 00:08:57,980 --> 00:09:08,060 it says if something was selected, put another end, let's format go up to here format document, that's 171 00:09:08,060 --> 00:09:08,810 pretty good. 172 00:09:08,840 --> 00:09:12,200 So now we're only going to go we're going to check to see if it was owned. 173 00:09:12,200 --> 00:09:13,610 We're going to get a message. 174 00:09:13,640 --> 00:09:16,220 If it is owned. 175 00:09:16,220 --> 00:09:20,000 If it's not, we'll go in here, see if there's enough money. 176 00:09:20,330 --> 00:09:22,370 What if there's not enough money? 177 00:09:22,790 --> 00:09:24,920 Let's get rid of this print statement. 178 00:09:25,640 --> 00:09:31,010 I put a m g ll be ll dot text equals. 179 00:09:31,010 --> 00:09:37,940 I'm going to make that a capital n not enough money, maybe an exclamation mark. 180 00:09:39,170 --> 00:09:41,840 And then down here, I don't need this print anymore. 181 00:09:41,840 --> 00:09:43,220 Buying is going to be obvious. 182 00:09:43,220 --> 00:09:44,300 We're actually going to buy it. 183 00:09:46,190 --> 00:09:47,530 Oops, This got a little bit here. 184 00:09:47,540 --> 00:09:49,280 Let me let me stress that out a little bit. 185 00:09:49,310 --> 00:09:50,210 There we go. 186 00:09:50,810 --> 00:09:52,930 Under the shop fire. 187 00:09:52,940 --> 00:09:56,540 Ari, I think I'll do my clear, clear fields. 188 00:09:56,540 --> 00:09:57,790 So we bought something. 189 00:09:57,800 --> 00:09:59,570 We're going to clear the fields out. 190 00:09:59,570 --> 00:10:02,390 And then I think I'm going to close my window. 191 00:10:02,390 --> 00:10:03,200 We bought it. 192 00:10:03,200 --> 00:10:03,740 Boom! 193 00:10:03,740 --> 00:10:04,730 Close it. 194 00:10:04,880 --> 00:10:06,650 Shop frame. 195 00:10:07,760 --> 00:10:12,320 Dot visible equals false. 196 00:10:12,320 --> 00:10:13,750 We're going to close that. 197 00:10:13,760 --> 00:10:22,160 I think I'm going to get my clear fields and I'm going to put them when I open the shop to right just 198 00:10:22,160 --> 00:10:23,780 in case I had something selected. 199 00:10:23,780 --> 00:10:25,250 I go back to the shop. 200 00:10:25,250 --> 00:10:26,660 I may not want that anymore. 201 00:10:26,660 --> 00:10:28,250 I don't want to accidentally buy it. 202 00:10:28,250 --> 00:10:33,890 So I'll do a clear field here and you can do it before or after the ding. 203 00:10:33,890 --> 00:10:34,430 It doesn't matter. 204 00:10:34,430 --> 00:10:35,600 You can put it anywhere in here. 205 00:10:35,600 --> 00:10:37,160 I don't know why I put it in the middle. 206 00:10:37,520 --> 00:10:37,790 All right. 207 00:10:37,790 --> 00:10:39,290 I think we're good to go. 208 00:10:39,530 --> 00:10:40,940 I think we got everything. 209 00:10:41,890 --> 00:10:42,580 Let's try it. 210 00:10:43,590 --> 00:10:47,130 Just got back real quick is That looks good. 211 00:10:49,000 --> 00:10:53,680 We didn't do anything with a for loop for the tax fields are clear. 212 00:10:53,680 --> 00:10:55,480 Fields is good. 213 00:10:56,630 --> 00:10:59,080 And then we have our message label to find. 214 00:10:59,090 --> 00:10:59,870 All right. 215 00:11:00,990 --> 00:11:01,950 Play. 216 00:11:06,580 --> 00:11:11,740 And I got 2150 points, so I should have enough money to make some purchases. 217 00:11:12,100 --> 00:11:13,780 Simple pistol. 218 00:11:14,440 --> 00:11:15,340 I'm going to buy it. 219 00:11:16,330 --> 00:11:16,690 There you go. 220 00:11:16,730 --> 00:11:17,620 I got it. 221 00:11:17,650 --> 00:11:19,160 What happens if I open this up? 222 00:11:19,630 --> 00:11:20,450 Fields are cleared. 223 00:11:20,470 --> 00:11:21,460 That's good. 224 00:11:21,490 --> 00:11:23,680 Maybe buy this again. 225 00:11:24,370 --> 00:11:26,560 You found the item? 226 00:11:26,560 --> 00:11:28,450 It was in your backpack. 227 00:11:28,480 --> 00:11:30,130 What if I'm carrying it? 228 00:11:30,310 --> 00:11:31,960 You can't see that I'm carrying it. 229 00:11:31,960 --> 00:11:33,220 But I hit that. 230 00:11:33,770 --> 00:11:35,050 I'm going to buy it again. 231 00:11:36,500 --> 00:11:37,810 I found the item. 232 00:11:37,810 --> 00:11:38,920 It was equipped. 233 00:11:39,340 --> 00:11:41,050 All right, That's pretty cool. 234 00:11:41,080 --> 00:11:46,030 What about the fabulous Lemon 2000? 235 00:11:46,030 --> 00:11:47,850 So we don't have enough money. 236 00:11:47,860 --> 00:11:48,880 Let's buy it. 237 00:11:49,980 --> 00:11:51,920 Oh, not enough money. 238 00:11:51,940 --> 00:11:53,560 I think that's pretty cool. 239 00:11:54,490 --> 00:11:59,110 So we've got we've got a fairly highly functional store going. 240 00:12:01,130 --> 00:12:06,110 The one thing, though, we don't persist the object. 241 00:12:06,110 --> 00:12:07,220 So we bought this. 242 00:12:07,220 --> 00:12:10,880 If I leave the game, if I come back, it's gone. 243 00:12:10,880 --> 00:12:12,860 What happens if I die? 244 00:12:14,680 --> 00:12:14,920 That. 245 00:12:18,610 --> 00:12:21,730 Ah, Bomber gone and I'm out 1000 bucks. 246 00:12:21,730 --> 00:12:24,550 So you'll have to make decisions whether you want to save or not. 247 00:12:24,790 --> 00:12:27,700 In the next video, I'm going to show you how to save it.